package com.dmall.scf.utils

import java.io.{PrintWriter, StringWriter}
/**
 * @descrption
 * scf
 * @author wangxuexing
 * @date 2019/12/23
 */
object ExceptionUtil{
  /**
   *
   * 功能说明:在日志文件中 ，打印异常堆栈
   * @param e : Throwable
   * @return : String
   */
  def getExceptionStack(e: Throwable): String = {
    ScalaFunction.tryWithResources(new StringWriter){errorsWriter=>
      ScalaFunction.tryWithResources(new PrintWriter(errorsWriter)){out=>
        e.printStackTrace(out)
      }
      errorsWriter.toString
    }
  }
}
